
<!DOCTYPE html>
<html xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>元数据</title>
    <link href="/static/devtools30/layui-v2.5.6/css/layui.css" rel="stylesheet" />
    <link href="/static/devtools30/css/devindexbase.css" rel="stylesheet" />
    <link href="/static/devtools30/layui-v2.5.6/ext/soulTable/soulTable.css" rel="stylesheet"/>

    <script src="/static/devtools30/js/jquery-1.11.2.min.js" type="text/javascript"></script>
    <script src="/static/devtools30/layui-v2.5.6/layui.all.js" type="text/javascript"></script>
    <script src="/static/devtools30/layui-v2.5.6/layui.js" type="text/javascript"></script>
    <script src="/static/devtools30/js/devtoolCommon.js" type="text/javascript"></script>
    <link href="/static/devtools30/js/plugins/codemirror-5.14.2/theme/eclipse.css" rel="stylesheet" type="text/css" />
    <link href="/static/devtools30/js/plugins/codemirror-5.14.2/lib/codemirror.css" rel="stylesheet" />
    <script src="/static/devtools30/js/plugins/codemirror-5.14.2/lib/codemirror.js" type="text/javascript"></script>
    <script src="/static/devtools30/js/plugins/codemirror-5.14.2/mode/sql/sql.js" type="text/javascript"></script>
    <script src="/static/devtools30/js/plugins/codemirror-5.14.2/mode/javascript/javascript.js" type="text/javascript"></script>

    <style>
        /*顶部容器*/
        .tophead {
            height: 32px;
            border-bottom: 1px solid #F7F7F7;
            padding: 0 5px;
        }
        /*顶部输入框，下拉框去掉layui默认边距*/
        .tophead .layui-form-item {
            margin-bottom: 0px!important;
        }
        /*顶部输入框，下拉框左边文本样式*/
        .tophead .layui-form-label {
            padding: 0;
            line-height: 25px;
            width: auto;
        }
        /*顶部form块样式*/
        .tophead .layui-input-block {
            margin-left: 34px;
            min-height: 26px;
        }
        /*顶部输入框，下拉框设置高度*/
        .tophead .layui-input,
        .layui-select {
            height: 25px;
        }
        /*顶部下拉框设置子项高度*/
        .tophead .layui-form-select dl {
            top: 26px;
            padding: 0;
        }
        /*顶部下拉框设置子项内容高度*/
        .tophead .layui-form-select dl dd,
        .layui-form-select dl dt {
            line-height: 24px;
        }
        .tophead .layui-form-item {
            width: 165px;
            padding: 5px;
        }
        /*顶部下拉框图标大小*/
        .tophead .layui-form-select .layui-edge {
            border-width: 4px;
        }
        /*搜索框左边距*/
        .tophead .search .layui-input-block {
            margin-left: 32px;
        }

        /*表格-----------------------------------*/

        /*表格字体大小*/
        .layui-table td,
        .layui-table th {
            font-size: 11px!important;
        }
        /*表格边距*/

        .layui-table,
        .layui-table-view {
            margin: 0;
        }
        /*按钮高度大小*/
        .layui-btn {
            height: 26px;
            line-height: 26px;
            font-size: 11px;
        }
        /*按钮组-------------------------------*/
        /*按钮组左边框*/
        .layui-btn-group .layui-btn-primary:first-child {
            border-left: 1px solid #c9c9c9!important;
        }
        /*按钮组边框*/
        .layui-btn-group .layui-btn {
            border-left: 1px solid rgba(255, 255, 255, .5)!important;
        }
        .layui-tab {
            margin: 0px 0;
            text-align: left!important;
        }
    </style>

</head>
<body>
<div style="height: 100%;background: #F7F7F7;">
    <div class="flex flex-align-center flex-jusity-betreen tophead backgroundf">
        <div class="flex flex-align-center">
            <form class="layui-form" lay-filter="formTest">
            <div class="layui-form flex flex-align-center" >
                <div class="layui-form-item marginleft10 search">
                    <label class="layui-form-label">查询</label>
                    <div class="layui-input-block">
                        <input type="text" id="searchValue"  name="searchValue" placeholder="请输入指标对象代码/指标对象名称" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <button type="button" onclick="getZhibiaoObjList()" class="layui-btn layui-btn-sm layui-btn-normal marginleft10">确定</button>
            </div>
            </form>
        </div>
        <div class="layui-btn-group btns">
            <button type="button" class="layui-btn layui-btn-primary layui-btn-sm" name='101'>指标对象维护</button>
            <button type="button" class="layui-btn layui-btn-primary layui-btn-sm" name='103'>新增模型字段对应</button>
        </div>
    </div>
    <div class="flex flex-jusity-betreen " style="height:100%;width: 100%;background: #F7F7F7;padding: 3px 0;">
        <div class="backgroundf">
            <table  id="mygrid" lay-filter="mygrid"></table>
        </div>
        <div class="backgroundf" >
            <div class="layui-tab layui-tab-brief">
                <ul class="layui-tab-title">
                    <li class="layui-this">数据集</li>
                    <li>模型字段对应</li>
                </ul>
                <div class="layui-tab-content" style="height: 100px;">
                    <div class="layui-tab-item layui-show" >
                        <table id="mygrid3"  lay-filter="mygrid3"></table>
                    </div>

                    <div class="layui-tab-item ">
                        <table  id="mygrid2"  lay-filter="mygrid2"></table>
                    </div>
                </div>
            </div>
        </div>
    </div>

</div>

<script>
    var height = dlCommon.getWinHeight();
    var width=dlCommon.getWinWidth();
    var selzbobjid="";

    layui.config({
        base: '/static/devtools30/layui-v2.5.6/ext/',// 第三方模块所在目录
        version: 'v1.5.10' // 插件版本号
    }).extend({
        soulTable: 'soulTable/soulTable',
        tableChild: 'soulTable/tableChild',
        tableMerge: 'soulTable/tableMerge',
        tableFilter: 'soulTable/tableFilter',
        excel: 'soulTable/excel',
        dltable: 'treegrid/dltable',
        treeGrid:'treegrid/treeGrid'
    });
    layui.use(['form', 'table', 'jquery','treeGrid','layer','soulTable'], function(){
        $(function() {

            initGrid();

            initEvent();

            bindForm();

            getZhibiaoObjList();

        })
    });


    //数据表
    function getZhibiaoObjList(){

        var data={
            serach:$("#searchValue").val(),
            typeid:$("#selType").val()
        };

        dlCommon.getJSON("/DevtZbobjInfoEntityController/getAll",data,function(res){
            layui.table.render({
                id:"mygrid"
                ,elem: '#mygrid'
                ,height: height-36
                , width: width*0.20
                , size: 'sm'//小尺寸的表格
                ,data:res&&res.data?(res.data):[]
                ,cols: [
                    [
                        {field:'zbobjname',width:180,filter:true, title: '指标对象名称'},
                        {field:'zbobjcode', width:180,filter:true, title: '指标对象代码'}
                    ]]
                ,page:false,
                filter: {
                    bottom: false
                },
                done: function() {
                    // 在 done 中开启
                    layui.soulTable.render(this)
                }
            });
        });
        //单击表格
        layui.table.on('row(mygrid)', function(obj){
            selzbobjid=obj.data.id;
            getFieldList();
        });
    }
    //元数据字段
    function getFieldList(){
        if(!selzbobjid){
            return;
        }
        var data={
            zbobjid:selzbobjid
        };
        layui.table.reload("mygrid2",{
            url:"/DevtZbobjFieldEntityController/getAll",
            where:data,
            loading:true,
        });

        // layui.table.reload("mygrid3",{
        //     url:"/DevtZbobjInfoEntityController/getZbObjDataAll",
        //     where:data,
        //     loading:true,
        // });
        dlCommon.getJSON("/DevtZbobjInfoEntityController/getZbObjDataAll",data,function(res){
            layui.table.render({
                elem: '#mygrid3',
                height: height-100,
                width: width*0.795,
                size: 'sm', //小尺寸的表格
                loading:false,
                page: true, //开启分页
                limit: 30,
                limits: [30,60,90],
                data:res&&res.data?(res.data):[],
                cols: [
                    [ //表头
                        { field: 'xh', title: '序号', sort: true, width: 150, filter: true, },
                        { field: 'dm', title: '代码', sort: true, width: 150, filter: true, },
                        { field: 'mc', title: '名称', sort: true, width: 300, filter: true }
                    ]
                ],
                filter: {
                    bottom: false
                },
                done: function() {
                    // 在 done 中开启
                    layui.soulTable.render(this)
                }
            });
        })
    }

    function bindForm(){

        layui.form.render();
    }
    //初始化grid
    function initGrid(){

        //第2个实例
        layui.table.render({
            elem: '#mygrid2',
            height: height-100,
            width: width*0.795,
            size: 'sm', //小尺寸的表格
            loading:false,
            page: false, //开启分页
            limit: 30,
            limits: [30,60,90],
            cols: [
                [ //表头
                    { field: 'modelname', title: '对应模型名称', sort: true,filter: true, width: 150, },
                    { field: 'modelname', title: '对应模型代码', sort: true,filter: true, width: 150, },
                    { field: 'modelfieldname', title: '对应字段名称', sort: true,filter: true, width: 150 },
                    { field: 'modelfieldcode', title: '对应字段代码', sort: true,filter: true, width: 150 },
                    { field: 'opera', title: '操作', width: 120,templet: function(d){
                        var str="";
                        str += '<button type="button" onclick="delField(\''+d.id+'\')" class="layui-btn layui-btn-danger layui-btn-xs layui_edit_btn">删除</button>';
                        return str;
                        }
                    }
                ]
            ],
            filter: {
                bottom: false
            },
            done: function() {
                // 在 done 中开启
                layui.soulTable.render(this)
            }
        });

        //第3个实例
        layui.table.render({
            elem: '#mygrid3',
            height: height-100,
            width: width*0.795,
            size: 'sm', //小尺寸的表格
            loading:false,
            page: false, //开启分页
            limit: 30,
            limits: [30,60,90],
            cols: [
                [ //表头
                    { field: 'xh', title: '序号', sort: true, width: 150,filter: true, },
                    { field: 'dm', title: '代码', sort: true, width: 150,filter: true, },
                    { field: 'mc', title: '名称', sort: true, filter: true,width: 300 }
                ]
            ],
            filter: {
                bottom: false
            },
            done: function() {
                // 在 done 中开启
                layui.soulTable.render(this)
            }
        });
    }
    //初始化事件
    function initEvent(){
        //按钮点击
        $('.btns>button').on('click', function() {
            var names = $(this)[0].name;
            if(names == '101') {
                dlCommon.layeropen(900,height*0.8,'分类维护','/V_DevtZbobjInfoEntityController/toList',{
                    end:function () {
                        bindForm();
                        getZhibiaoObjList();
                        getFieldList();
                    }
                })
                return;
            }
            if(!selzbobjid){
                dlCommon.layerInfo('请选择指标对象');
                return;
            }
            if(names == '103') {

                dlCommon.layeropen(900,height*0.8,'绑定模型字段','/DevtZbobjFieldEntityController/edit?zbobjid='+selzbobjid,{
                    end:function () {
                        bindForm();
                        getZhibiaoObjList();
                        getFieldList();
                    }
                })

            }

        })

    }
    function editField(id){
        dlCommon.layeropen(800,height*0.8,'绑定模型字段','/DevtZbobjFieldEntityController/edit?id='+id+'&zbobjid='+selzbobjid,{
            end:function () {
                bindForm();
                getZhibiaoObjList();
                getFieldList();
            }
        })
    }
    function delField(id) {
        if(!id){
            return;
        }
        dlCommon.layerConfirm("是否确定删除该表字段？",function(){
            dlCommon.getJSON("/DevtZbobjFieldEntityController/delete",{id:id},function(res){
                if(!res.success){
                    dlCommon.layerError(res.msg);
                    return;
                }
                getFieldList();
            })
        })

    }

</script>
</body>
</html>
